var elems = document.body.getElementsByTagName("video");
for(var i = 0; i < elems.length; i++)
{
	elems[i].setAttribute("preload","none");
}

// Get the HTTP Object
function getHTTPObject() {
	if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest) return new XMLHttpRequest();
	else {
		alert("Your browser does not support AJAX.");
		return null;
	}
}

function wrapBBCode(tag) {
	var msgInput = document.getElementById('msg');
	var content = msgInput.value;
	var selectedContent = content.substring(msgInput.selectionStart, msgInput.selectionEnd);
	var beforeContent = content.substring(0, msgInput.selectionStart);
	var afterContent = content.substring(msgInput.selectionEnd, content.length);
	msgInput.value = beforeContent + '[' + tag + ']' + selectedContent + '[/' + tag + ']' + afterContent;
}

function userTag(tag) {
	var msgInput = document.getElementById('msg');
	var content = msgInput.value;
	var beforeContent = content.substring(0, msgInput.selectionStart);
	var afterContent = content.substring(msgInput.selectionEnd, content.length);
	msgInput.value = beforeContent + '@' + tag + afterContent;
}

// For dynamic reacting without leaving page.
function userReact(user, postid) {
	ajaxGet = getHTTPObject();
	if (ajaxGet != null) {
		link = "index.php?do=react&user="+user+"&pid="+postid;
		ajaxGet.open("GET", link , true);
		ajaxGet.send(null);
		setTimeout(function(){ window.location.reload(); }, 1000);
	}
}

// For dynamic reacting without leaving page.
function userClrNotifications() {
	ajaxGet = getHTTPObject();
	if (ajaxGet != null) {
		link = "index.php?do=clrnote";
		ajaxGet.open("GET", link , true);
		ajaxGet.send(null);
		setTimeout(function(){ window.location.reload(); }, 1000);
	}	
}
